package com.ruoyi.system.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.CustomerCoupon;
import com.ruoyi.system.domain.Param.CustomerCouponParam;
import com.ruoyi.system.service.CustomerCouponService;
import com.ruoyi.system.mapper.CustomerCouponMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author 123
 * @description 针对表【customer_coupon】的数据库操作Service实现
 * @createDate 2024-10-22 21:48:54
 */
@Service
public class CustomerCouponServiceImpl extends ServiceImpl<CustomerCouponMapper, CustomerCoupon>
        implements CustomerCouponService {

    @Autowired
    private CustomerCouponMapper customerCouponMapper;

    /**
     * 使用优惠卷领取信息 //todo 用户使用优惠卷修改状态
     *
     * @return 结果
     */
    @Override
    public int updateCustomerCoupon(CustomerCouponParam customerCouponParam) {
//        //使用过或者过期都可被修改
        CustomerCoupon customerCoupon = new CustomerCoupon();
        customerCoupon.setCustomerCouponId(Math.toIntExact(customerCouponParam.getCustomerCouponId()));
        customerCoupon.setOrderId(customerCouponParam.getOrderId());
        customerCoupon.setStatus(1L);
        customerCoupon.setUsedTime(new Date());
        return customerCouponMapper.updateCustomerCoupon(customerCoupon);
    }

}




